/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package stuff.web;

import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;

/**
 *
 * @author Николай
 */
@Controller
public class IndexCntrl {

    Map<String, String> linkAnonymous = new LinkedHashMap<String, String>();
    Map<String, String> linkUser = new LinkedHashMap<String, String>();
    Map<String, String> linkRoot = new LinkedHashMap<String, String>();
    Map<String, String> linkDocs = new LinkedHashMap<String, String>();

    public IndexCntrl() {
        linkAnonymous.put("account.create", "");
        
        linkUser.put("account.edit", "");
        linkUser.put("logout", "");

        linkRoot.put("account.create", "");
        linkRoot.put("account.edit", "");
        linkRoot.put("account.list", "");
        linkRoot.put("logout", "");

        linkDocs.put("docs.login", "");
    }

    //default page
    @RequestMapping(value="/")
    String index(Model model) {
        model.addAttribute("content", "/WEB-INF/docs/login.html");
        return "/index";
    }

    @RequestMapping(value="/docs/{name}")
    String handler(Model model, @PathVariable("text") String text, @PathVariable("name") String name) {
        model.addAttribute("content", String.format("/WEB-INF/%s/%s.html", text, name));
        return "/index";
    }
}
